{extend name="common/layout" /}
{block name="content"}

<script>
var PURL = '<?php echo $purl;?>';
$(document).ready(function(){
    $('#area_info').nc_region();
});
</script>
<link href="__SHOP_DEFAULT__/css/store_list.css" rel="stylesheet" type="text/css">
<link href="__SITE_RESOURCE__/js/jcarousel/skins/tango/skin.css" rel="stylesheet" type="text/css">
<style type="text/css">
.sticky #main-nav { width: 1198px;}
.jcarousel-skin-tango .jcarousel-clip-horizontal { width: 1000px !important; height: 225px !important;}
.jcarousel-skin-tango .jcarousel-item { height: 225px !important;}
.jcarousel-skin-tango .jcarousel-container-horizontal { width: 1000px !important;}
</style>

<script type="text/javascript" src="__SHOP_RESOURCE__/js/Jquery.Query.js" charset="utf-8"></script>
<script type="text/javascript">
/* 替换参数 */
function ss_replaceParam(key, value)
{
    location.assign($.query.set('key', key).set('order', value));
}

/* 替换参数 */
function ss_dropParam(key1, key2)
{
	location.assign($.query.REMOVE(key1).REMOVE(key2));
}

/* 替换参数 */
function ss_dropParam2(key1)
{
	location.assign($.query.REMOVE(key1));
}

/* 替换参数 */
function ss_replaceParam2(key, value)
{
    location.assign($.query.set(key, value, value));
}

$(function (){
    var order = '<?php echo I("param.order");?>';
    var arrow = '';
    var class_val = 'sort_desc';

    switch (order){
        case 'store_credit desc' : order = 'store_credit asc';  class_val = 'sort_desc'; break;
        case 'store_credit asc'  : order = 'store_credit desc'; class_val = 'sort_asc' ; break;
        default : order = 'store_credit asc';
    }
    $('#credit_grade').addClass(class_val);
    $('#credit_grade').click(function(){query('order', order);return false;});
}
);

function query(name, value){
    $("input[name='"+name+"']").val(value);
    $('#searchStore').submit();
}


</script>
<div class="nch-breadcrumb wrapper"><i class="icon-home"></i>
	{volist name="nav_link_list" id="nav_link"}
		{if(!empty($nav_link['link']))}
			<span>
				<a href="{$nav_link['link']}">{$nav_link['title']}</a>
			</span>
			<span class="arrow">></span>
		{else /}
			<span>{$nav_link['title']}</span>
	    {/if}
	{/volist}
</div>
<div class="content">
<div class="nc-store-class">
  <?php if(!empty($class_list) && is_array($class_list)){?>
  <dl>
    <dt>店铺类目：</dt>
    <dd>
      <a href="<?php echo url('shop/Storelist/index');?>">所有店铺</a>
      <?php foreach($class_list as $k=>$v){?>
	      <?php if (I('param.cate_id') == $v['sc_parent_id']){?>
	      <a href="<?php echo url('shop/Storelist/index',array('cate_id'=>$k));?>"><?php echo $v['sc_name'];?></a>
	      <?php }elseif (!isset($v['child']) && $class_list[I('param.cate_id')]['sc_parent_id'] == $v['sc_parent_id']){?>
	      <a href="<?php echo url('shop/Storelist/index',array('cate_id'=>$k));?>"><?php echo $v['sc_name'];?></a>
	      <?php }?>
      <?php }?>
    </dd>
  </dl>
  <?php }?>
</div>
<div class="sort-bar">
  <div class="shop_con_list" id="main-nav-holder">
    <nav class="nc-gl-sort-bar" id="main-nav">
      <form id="store_list" method="GET" action="{:url('index')}">
        <input type="hidden" name="order" value="<?php echo I('param.order');?>"/>
        <input type="hidden" name="act" value="store_list"/>
        <input type="hidden" name="cate_id" value="<?php echo I('param.cate_id');?>"/>
        <div class="sort-bar"><!-- 排序方式S -->
          <ul class="array">
          <!-- 默认 -->
            <li <?php if(!I('param.key')){?>class="selected"<?php }?>><a href="javascript:void(0)" class="nobg" onclick="javascript:ss_dropParam('key','order');" title="默认排序">默认</a></li>
            <!-- 销量 -->
            <li <?php if(I('param.key') == 'store_sales'){?>class="selected"<?php }?>><a href="javascript:void(0)" <?php if(I('param.key') == 'store_sales'){?>class="<?php echo I('param.order');?>"<?php }?> onclick="javascript:ss_replaceParam('store_sales','<?php echo (I('param.order') == 'desc' && I('param.key') == 'store_sales')?'asc':'desc' ?>');" title="<?php echo (I('param.order') == 'desc' && I('param.key') == 'store_sales')?'点击按销量从低到高排序':'点击按销量从高到低排序'; ?>">销量</a></li>
            <!-- 信用 -->
            <li <?php if(I('param.key') == 'store_credit'){?>class="selected"<?php }?>><a href="javascript:void(0)" <?php if(I('param.key') == 'store_credit'){?>class="<?php echo I('param.order');?>"<?php }?> onclick="javascript:ss_replaceParam('store_credit','<?php  echo (I('param.order') == 'desc' && I('param.key') == 'store_credit')?'asc':'desc' ?>');" title="<?php  echo (I('param.order') == 'desc' && I('param.key') == 'store_credit')?'点击按信用从低到高排序':'点击按信用从高到低排序'; ?>">信用</a></li>
          </ul>
          <!-- 排序方式E -->
          
          <div class="sidebox">
            <h5 class="title">店铺名称：</h5>
            <div class="selectbox">
              <input class="text" type="text" name="keyword" value="<?php echo I('param.keyword');?>" style=" width:150px;"/>
            </div>
          </div>
          <div class="sidebox">
            <h5><label for="area_info">店铺所在地：</label></h5>
            <div class="selectbox">
              <input id="area_info" name="area_info" type="hidden" value=""/>
            </div>
          </div>
          <div class="sidebox width5" style=" background-image: none">
            <div class="selectbox">
              <input class="btn" type="submit" value="搜索" />
            </div>
          </div>
          
        </div>
      </form>
    </nav>
  </div>
</div>
<ul class="nc-store-list">
<?php if(!empty($store_list) && is_array($store_list)){?>
<?php foreach($store_list as $skey => $store){?>
    <li class="item">
      <dl class="shop-info">
        <dt class="shop-name">
        	<a href="<?php echo url('shop/Showstore/index', array('store_id'=>$store['store_id']));?>" target="_blank"><?php echo $store['store_name'];?></a> 
        	<img src="__SHOP_DEFAULT__<?php echo '/images/store_grade/'.$store['grade_id'].'.png'; ?>" class="pngFix">
        </dt>
        <dd class="shop-pic">
        	<a href="<?php echo url('shop/Showstore/index', array('store_id'=>$store['store_id']));?>" title="" target="_blank">
        		<span class="size72">
        			<img src="__UPLOAD_PATH__/shop/common/loading.gif" rel="lazy" data-url="__UPLOAD_PATH__/shop/store/<?php echo $store['store_avatar'];?>"  alt="<?php echo $store['store_name'];?>" title="<?php echo $store['store_name'];?>" class="size72" />
        		</span>
        	</a>
        	<a href="javascript:collect_store('<?php echo $store['store_id'];?>','count','store_collect')" >收藏店铺<span>(<em nctype="store_collect"><?php echo $store['store_collect']?></em>)</span></a>
        </dd>
        
        <dd class="shopkeeper">店主：<?php echo $store['member_name'];?>
        	<a target="_blank" class="message" href="{:url('member/Message/sendmsg', array('member_id'=>$store['member_id']))}"></a><dd>
	<dd class="main-runs" title="<?php echo $store['store_zy']?>">主营：<?php echo $store['store_zy']?></dd>
	</dd>
      </dl>

      <dl class="w150">
        <dd><?php echo ($tmp = $store['goods_count']) ? '商品数量'.$tmp.'件' : '暂无商品';?></dd>
        <dd><?php echo ($tmp = $store['num_sales_jq']) ? '最近成交'.$tmp.'笔' : '暂无销量';?></dd>
        <?php if (!empty($store['search_list_goods'])){?>
        <dd class="more-on" attr='morep' nc_type='<?php echo $skey;?>'><span>收起相关商品</span><i></i></dd>
        <?php }?>
      </dl>
      <dl class="w200">
      	<!-- 店铺信用度 -->
        <dd><?php if (empty($store['store_credit_average'])){ echo '暂无信用'; }else {?>
          信用度：
          <span class="seller-heart level-<?php echo floor($store['store_credit_average']) ?>"></span>
          <?php }?>
        </dd>
        <!-- 店铺好评率 -->
        <dd>
        <?php if (empty($store['store_credit_percent'])){?>
        	暂无评价
        <?php }else{?>	
        	好评率：{$store['store_credit_percent']}%
        <?php }?>
        </dd>
        <!-- 店铺动态评分 -->
        <dd class="shop-rate" nc_type="shop-rate" store_id='<?php echo $store['store_id'];?>'>店铺动态评分：<span><i></i></span>
          <div class="shop-rate-con">
              <div class="arrow"></div>
              <dl class="rate">
                <?php  foreach ($store['store_credit'] as $key=>$value) {?>
                  <dt><?php echo $value['text'];?>：</dt>
                  <dd class="rate-star"><em><i style=" width: <?php echo @round($value['credit']/5*100,2);?>%;"></i></em><span><?php echo $value['credit'];?>分</span></dd>
                <?php } ?>
              </dl>
          </div>
          </dd>
      </dl>
      <dl class="w250">
       
	<?php if(!empty($store['store_phone'])){?>
	电话：<?php echo $store['store_phone']; ?>
	<?php }?>
	</dd>
	<dd>
	客服：
        <?php if(!empty($store['store_qq'])){?>
          <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=<?php echo $store['store_qq'];?>&site=qq&menu=yes" title="QQ: <?php echo $store['store_qq'];?>"><img border="0" src="http://wpa.qq.com/pa?p=2:<?php echo $store['store_qq'];?>:52" style=" vertical-align: middle;"/></a>
        <?php }?>
        <?php if(!empty($store['store_ww'])){?>
          <a target="_blank" href="http://amos.im.alisoft.com/msg.aw?v=2&uid=<?php echo $store['store_ww'];?>&site=cntaobao&s=2&charset=utf-8" ><img border="0" src="http://amos.im.alisoft.com/online.aw?v=2&uid=<?php echo $store['store_ww'];?>&site=cntaobao&s=2&charset=utf-8" alt="Wang Wang" style=" vertical-align: middle;" /></a>
        <?php }?>
	</span>
	<span member_id="<?php echo $store['member_id'];?>"></span>
	
	</dd>
	 <dd>
	 <?php if(!empty($store['area_info'])){?>
	 地址：<?php echo $store['area_info'];?>
	 <?php }?>
	 </dd>
        <dd>
       </dl>
      
      <?php if(!empty($store['search_list_goods']) && is_array($store['search_list_goods'])){?>
      <div class="nc-shop-goodslist" nc_type='goods_<?php echo $skey;?>'>
        <div class="arrow"></div>
        <ul class="jcarousel-skin-tango" nc_type="jcarousel" >
        <?php foreach($store['search_list_goods'] as $k=>$v){?>
        <li>
            <dl>
              <dt class="goods-pic"><span class="thumb size160"> <i></i> <a href="{:url('shop/Goods/index',array('goods_id'=>$v['goods_id']))}" target="_blank"> 
              	<img  onload="javascript:DrawImage(this,160,160);" alt="<?php echo $v['goods_name'];?>" width="160" height="160"  src="<?php echo thumb($v,'small');?>"></a></span></dt>
              <dd class="goods-name"><a href="<?php echo url('shop/Goods/index',array('goods_id'=>$v['goods_id']));?>" title="<?php echo $v['goods_name'];?>" target="_blank"><?php echo $v['goods_name'];?></a></dd>
              <dd class="goods-price"><em><?php echo $v['goods_price'];?></em></dd>
              <dd class="goods-sales">最近成交<?php echo $v['goods_salenum'];?>笔</dd>
            </dl>
          </li>
         <?php }?>
        </ul>
      </div>
      <?php }?>
    </li>

<?php }?>

<?php }else{?>
<div id="no_results">没有找到符合条件的店铺</div>
<?php }?>
</ul>
<div class="pagination"> <?php echo $show_page;?> </div>
</div>
<script type="text/javascript" src="__SITE_RESOURCE__/js/waypoints.js"></script> 
<script type="text/javascript" src="__SITE_RESOURCE__/js/jcarousel/jquery.jcarousel.min.js"></script> 

<script type="text/javascript">
$(function(){
	//图片轮换
    $('[nc_type="jcarousel"]').jcarousel({visible: 4});
    $('[attr="morep"]').click(function(){
    	var id = $(this).attr('nc_type');
    	if($(this).attr('class')=='more-off'){
    		$(this).addClass('more-on').removeClass('more-off').html('收起相关商品<i></i>');
    		$('div[nc_type="goods_'+id+'"]').show();
    	}else{
    		$(this).addClass('more-off').removeClass('more-on').html('展开相关商品<i></i>');
    		$('div[nc_type="goods_'+id+'"]').hide();
    	}
    });
   
});
</script>
{/block}
